﻿using System;
using System.ServiceModel;
using Ayatta.Contract.Domain;
using System.Collections.Generic;

namespace Ayatta.Contract
{
    [ServiceContract(Namespace = ServiceContract.Namespace)]
    public interface ITradeService : IService
    {
        #region Order

        [OperationContract]
        MagicKit OrderCreate(Order o);

        [OperationContract]
        bool CreateGameOrder(Order o);

        [OperationContract]
        bool OrderAddressInvoiceSet(string id, int userId, UserAddress address, UserInvoice invoice);

        [OperationContract]
        Order GetOrderMemo(string id, int userId, bool isSeller);

        [OperationContract]
        bool UpdateOrderMemo(string id, int userId, bool isSeller, byte? flag, string memo);

        [OperationContract]
        bool UpdateOrderBuyerMessage(string id, int userId, string message);

        [OperationContract]
        bool UpdateOrderAddress(string id, int userId, bool isSeller, UserAddress address);

        [OperationContract]
        Order OrderStatusGet(string id, int? userId, bool isSeller);

        [OperationContract]
        bool OrderStatusUpdate(string id, int userId, bool isSeller, OrderStatus status,string message = null);

        [OperationContract]
        bool UpdateOrderExpiration(string id, int userId, int delay);

        [OperationContract]
        bool DeleteOrder(string id);

        //[OperationContract]
        //string GetAuctionOrderId(long userId, long auctionId);

        [OperationContract]
        Order GetOrder(string id);

        [OperationContract(Name = "GetOrderWithDetails")]
        Order GetOrder(string id, int? userId = null, bool inclItem = false, bool isSeller = false,
                       bool inclNote = false);

        [OperationContract]
        PagedList<Order> GetPagedOrders(int index = 1, int size = 20, string id = null, int? userId = null,
                                       string nick = null, bool isSeller = false, string title = null,
                                       OrderCategory category = OrderCategory.Normal,
                                       OrderStatus? orderStatus = null, byte? commentStatus = null,
                                       DateTime? beginDate = null, DateTime? endDate = null);

        [OperationContract]
        OrderItem GetOrderItem(string id, int userId, bool isSeller, bool inclOrder = false);

        [OperationContract]
        PagedList<Order> OrderPagedList(int page = 1, int size = 20, string id = null, string name = null, bool isSeller = false, int? userId = null, string userName = null, OrderCategory category = OrderCategory.Normal, OrderStatus? status = null, byte? comment = null, DateTime? beginDate = null, DateTime? endDate = null);
       
        [OperationContract]
        OrderItem GetOrderItemStatus(string id, int userId, bool isSeller);

        [OperationContract]
        bool UpdateOrderItemRefundStatus(string id, int userId, bool isSeller, RefundStatus status, byte[] version,
                                         string refundId);

        [OperationContract]
        IList<OrderItem> GetOrderItems(string[] orderIds);

        [OperationContract]
        bool OrderConfirm(string shippingId, int userId);

        [OperationContract]
        bool OrderAutoFinished(UserTrade trade, Order order);

        /// <summary>
        /// 获取兑换信息
        /// 竞拍获得的拍品兑换为积分或免费拍币
        /// </summary>
        /// <param name="orderId">竞购订单Id</param>
        /// <param name="userId">买家Id </param>
        /// <returns></returns>
        [OperationContract]
        OrderExchangeDetail GetOrderExchangeDetail(string orderId, int userId);
        #endregion

        #region Refund

        [OperationContract]
        bool CreateRefund(Refund o);

        [OperationContract]
        Refund GetRefund(string id, int userId, bool isSeller = false);

        #endregion

        #region Shipping

        [OperationContract]
        MagicKit OrderShipmentCreate(string orderId, string orderItemId, OrderStatus orderStatus, int senderId,bool multiple, Shipment o);

        [OperationContract]
        Shipment ShipmentGet(string id);

        [OperationContract]
        IList<Shipment> OrderShipmentGet(string orderId);

        [OperationContract]
        string GetSplitShippingOrderId(string orderId);

        #endregion
    }
}
